package org.example.springmybatisdemo.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springmybatisdemo.entity.Dept;
import org.example.springmybatisdemo.entity.Emp;
import org.example.springmybatisdemo.entity.EmpQueryParam;

import java.util.List;

@Mapper
public interface EmpMapper {
//    @Select("select * from emp")
    public List<Emp> pagelist(EmpQueryParam param);

    @Select("select * from emp where username=#{username} and password=#{password} limit 1")
    Emp selectUsernameAndPassword(Emp emp);

//    新增员工基本信息 获取主键值必须用同一种方式要么用@Options(useGeneratedKeys = true, keyProperty = "id") 要么用@SelectKey
//    @Options(useGeneratedKeys = true, keyProperty = "id") // 获取主键值并复制给id属性
//    @Insert("insert into emp(id, username, password, name, gender, phone, job, salary, image, entrydate, dept_id, create_time, update_time) values (null, #{username}, #{password}, #{name}, #{gender}, #{phone}, #{job}, #{salary}, #{image}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})")
    int insert(Emp emp);
}
